/*
 * @lc app=leetcode.cn id=53 lang=golang
 *
 * [53] 最大子序和
 */

// @lc code=start


func maxSubArray(nums []int) int {
	maxAns := nums[0]
	pre := 0
	for _,v:=range nums{
		pre  = max(v,v+pre)
		maxAns = max(pre,maxAns)
	}
	return maxAns
	
}


func max(i, j int)int{
	if i>j{
		return i 
	}
	return j 
}



// @lc code=end
